package com.iplant.basic.serviceImpl.dao.bfc;

import com.iplant.base.po.OutResult;
import com.iplant.base.utils.annotation.dao.DBBaseDAO;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bfc.BFCSystemConfig;
import com.iplant.basic.service.po.bms.BMSEmployee;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@DBBaseDAO(BFCSystemConfig.class)
@Slf4j
public class BFCSystemConfigDAO extends BaseDAO {

    private static BFCSystemConfigDAO Instance = null;

    public static BFCSystemConfigDAO getInstance() {
        if (Instance == null) {
            Instance = new BFCSystemConfigDAO();
        }
        return Instance;
    }

    public BFCSystemConfigDAO() {
        super("");
        this.Init();
    }

    public BFCSystemConfig BFC_GetSystemConfigByName(BMSEmployee wLoginUser, int wType, String wName,
                                                     OutResult<Integer> wErrorCode) {
        Map<String, Object> wParams = new HashMap<>();
        wParams.put("NameEQ", wName);
        wParams.put("Type", wType);
        return this.SelectPO(wLoginUser, wParams, wErrorCode);
    }

    public String BFC_GetValueByName(BMSEmployee wLoginUser, int wType, String wName,
                                     OutResult<Integer> wErrorCode) {
        Map<String, Object> wParams = new HashMap<>();
        wParams.put("NameEQ", wName);
        wParams.put("Type", wType);
        BFCSystemConfig wBFCSystemConfig = this.SelectPO(wLoginUser, wParams, wErrorCode);
        if (wBFCSystemConfig == null)
            return "";
        return wBFCSystemConfig.Value;
    }

}
